package com.ciis.base.param.controller;

import com.ciis.base.param.model.TbSysParam;
import com.ciis.base.param.service.ISysParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: zhangdajun
 * Date: 14-4-12
 * Time: 下午9:58
 * To change this template use File | Settings | File Templates.
 */
@Controller
@RequestMapping("/sysparam")
public class SysParamController {

    @Autowired
    ISysParamService sysParamService;

    @RequestMapping(value="/intoImgParam",method = RequestMethod.GET)
    public String intoImgParam() throws Exception{
        return "web/back/attach/sortImgDesign";
    }

    @RequestMapping(value="/saveImgParam",method = RequestMethod.POST)
    public @ResponseBody boolean saveImgParam(String param_value,String param_key) throws Exception{
        try{
            TbSysParam param = new TbSysParam();
            param.setParam_key(param_key);
            param.setParam_value(param_value);
            sysParamService.saveSysParam(param);
        }catch(Exception ex){
            ex.printStackTrace();
            return false;
        }
        return true;
    }

    @RequestMapping(value="/getSysParamByKey",method = RequestMethod.GET)
    public @ResponseBody List<TbSysParam> getSysParamByKey(String param_key) throws Exception{
        sysParamService.findPage(param_key);
        return null;
    }
}
